home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / lwres / net.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-09-17  |  3.5 KB  |  136 lines

  1. /*
  2.  * Copyright (C) 2004, 2005  Internet Systems Consortium, Inc. ("ISC")
  3.  * Copyright (C) 2000-2002  Internet Software Consortium.
  4.  *
  5.  * Permission to use, copy, modify, and distribute this software for any
  6.  * purpose with or without fee is hereby granted, provided that the above
  7.  * copyright notice and this permission notice appear in all copies.
  8.  *
  9.  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  10.  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  11.  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  12.  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  13.  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  14.  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15.  * PERFORMANCE OF THIS SOFTWARE.
  16.  */
  17.  
  18. /* $Id: net.h,v 1.5.18.2 2005/04/29 00:17:23 marka Exp $ */
  19.  
  20. #ifndef LWRES_NET_H
  21. #define LWRES_NET_H 1
  22.  
  23. /*****
  24.  ***** Module Info
  25.  *****/
  26.  
  27. /*! \file net.h
  28.  * This module is responsible for defining the following basic networking
  29.  * types:
  30.  *
  31.  *\li        struct in_addr
  32.  *\li        struct in6_addr
  33.  *\li        struct sockaddr
  34.  *\li        struct sockaddr_in
  35.  *\li        struct sockaddr_in6
  36.  *
  37.  * It ensures that the AF_ and PF_ macros are defined.
  38.  *
  39.  * It declares ntoh[sl]() and hton[sl]().
  40.  *
  41.  * It declares lwres_net_aton(), lwres_net_ntop(), and lwres_net_pton().
  42.  *
  43.  * It ensures that #INADDR_LOOPBACK, #INADDR_ANY and #IN6ADDR_ANY_INIT
  44.  * are defined.
  45.  */
  46.  
  47. /***
  48.  *** Imports.
  49.  ***/
  50.  
  51. #include <lwres/platform.h>    /* Required for LWRES_PLATFORM_*. */
  52.  
  53. #include <unistd.h>
  54. #include <sys/types.h>
  55. #include <sys/socket.h>        /* Contractual promise. */
  56. #include <sys/ioctl.h>
  57. #include <sys/time.h>
  58. #include <sys/un.h>
  59.  
  60. #include <netinet/in.h>        /* Contractual promise. */
  61. #include <arpa/inet.h>        /* Contractual promise. */
  62. #ifdef LWRES_PLATFORM_NEEDNETINETIN6H
  63. #include <netinet/in6.h>    /* Required on UnixWare. */
  64. #endif
  65. #ifdef LWRES_PLATFORM_NEEDNETINET6IN6H
  66. #include <netinet6/in6.h>    /* Required on BSD/OS for in6_pktinfo. */
  67. #endif
  68. #include <net/if.h>    
  69.  
  70. #include <lwres/lang.h>
  71.  
  72. #ifndef LWRES_PLATFORM_HAVEIPV6
  73. #include <lwres/ipv6.h>        /* Contractual promise. */
  74. #endif
  75.  
  76. #ifdef LWRES_PLATFORM_HAVEINADDR6
  77. #define in6_addr in_addr6    /* Required for pre RFC2133 implementations. */
  78. #endif
  79.  
  80. /*!
  81.  * Required for some pre RFC2133 implementations.
  82.  * IN6ADDR_ANY_INIT and IN6ADDR_LOOPBACK_INIT were added in
  83.  * draft-ietf-ipngwg-bsd-api-04.txt or draft-ietf-ipngwg-bsd-api-05.txt.  
  84.  * If 's6_addr' is defined then assume that there is a union and three
  85.  * levels otherwise assume two levels required.
  86.  */
  87. #ifndef IN6ADDR_ANY_INIT
  88. #ifdef s6_addr
  89. #define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
  90. #else
  91. #define IN6ADDR_ANY_INIT { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } }
  92. #endif
  93. #endif
  94.  
  95. /*!
  96.  * Initialize address loopback.  See IN6ADDR_ANY_INIT
  97.  */
  98. #ifndef IN6ADDR_LOOPBACK_INIT
  99. #ifdef s6_addr
  100. #define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
  101. #else
  102. #define IN6ADDR_LOOPBACK_INIT { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } }
  103. #endif
  104. #endif
  105.  
  106. /*% Used by AI_ALL */
  107. #ifndef AF_INET6
  108. #define AF_INET6 99
  109. #endif
  110.  
  111.  
  112. /*% Used to return IPV6 address types. */
  113. #ifndef PF_INET6
  114. #define PF_INET6 AF_INET6
  115. #endif
  116.  
  117. /*% inaddr Loopback */
  118. #ifndef INADDR_LOOPBACK
  119. #define INADDR_LOOPBACK 0x7f000001UL
  120. #endif
  121.  
  122. LWRES_LANG_BEGINDECLS
  123.  
  124. const char *
  125. lwres_net_ntop(int af, const void *src, char *dst, size_t size);
  126.  
  127. int
  128. lwres_net_pton(int af, const char *src, void *dst);
  129.  
  130. int
  131. lwres_net_aton(const char *cp, struct in_addr *addr);
  132.  
  133. LWRES_LANG_ENDDECLS
  134.  
  135. #endif /* LWRES_NET_H */
  136.